when i am post same "data-object" with same "url-link" in postman, its working and my data is post successfully in postman. but when hit request through axios, there is accoured error "Request failed with status code 400". and my data is not posting. i tried to pass data object of axios, eg, "JSON.stringify(data)" but its not working and showing error "status 400". plez solve my query....
const Axios = require("axios");
export const uploadImages = (data) => async (dispatch) => {
dispatch({
type: "UPLOAD_IMAGES_INIT",
});
try {
const result = await Axios.post("http://localhost:4000/postImages", {
"id":1,
"name":"Flare Dress",
"price":12000,
"salePrice":20000,
"discount":10,
"pictures":[
"/assets/images/fashion/product/1.jpg",
],
"shortDetails":"Sed ut perspiciatis, unde omnis iste natu",
"description":"Lorem Ipsum is simply dummy text of",
"stock":16,
"new":true,
"sale":true,
"category":"women",
"colors":[
"yellow",
],
"size":[
"M",
],
"tags":[
"nike",
],
"rating":4,
"variants":[
{
"color":"yellow",
"images":"/assets/images/fashion/product/1.jpg"
},
],
"newPostImages":[
{
"images":"/assets/images/fashion/product/1.jpg"
},
]
});
} catch (err) {
const error = err.message || "Error Upload Images";
dispatch({
type: "UPLOAD_IMAGES_FAIL",
payload: error,
});
}
};
I got an answer to this question. There's a difference in the request structure from Postman and my code (No matter if using fetch or Axios). Yeah, it may happen that the current user does not have permissions for some entity, but in this case it's all about the following: